// run: $exec < input
#include <iostream>
#include <queue>

int const maxl = 66;
int const maxn = 1300;
int const maxm = 150;
bool a[maxl][maxn][maxm];
bool vis[maxl][maxn][maxm];
int opt[6][3] = {{0, 0, 1}, {0, 0, -1}, {0, 1, 0}, {0, -1, 0}, {1, 0, 0}, {-1, 0, 0}};
int n, m, l, t;

struct data
{
	int l, x, y;
};

bool inrange(data const & a)
{
	return 1 <= a.l && a.l <= l && 1 <= a.x && a.x <= n
					&& 1 <= a.y && a.y <= m;
}

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> m >> l >> t;
	for (int tl = 1; tl <= l; tl++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				std::cin >> a[tl][i][j];

	int ans = 0;
	std::queue<data> q;
	for (int tl = 1; tl <= l; tl++) {
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++) {
				if (vis[tl][i][j]) continue;
				if (!a[tl][i][j]) continue;
				q.push({tl, i, j});
				vis[tl][i][j] = true;
				int count = 0;
				while (!q.empty()) {
					auto now = q.front(); q.pop();
					count++;
					for (int ti = 0; ti < 6; ti++) {
						auto tmp = now;
						tmp.l += opt[ti][0];
						tmp.x += opt[ti][1];
						tmp.y += opt[ti][2];
						if (inrange(tmp) && !vis[tmp.l][tmp.x][tmp.y] && a[tmp.l][tmp.x][tmp.y]) {
							vis[tmp.l][tmp.x][tmp.y] = true;
							q.push({tmp.l, tmp.x, tmp.y});
						}
					}
				}
				if (count >= t) ans += count;
			}
	}
	std::cout << ans << '\n';
}

